home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-06 | 850 b | 50 lines | [TEXT/R*ch] |
- /***
- *
- * HexDump2.bob - Another example program to dump any file in
- * hexidecimal. This version produces less garbage
- * but is slightly more obscure.
- *
- ***/
-
- main ()
- {
- // if (getfile("TEXT"))
- if (getfile())
- ProcessFile();
- else
- print("*** ERROR: Couldn't get file ***\n");
- }
-
-
- HexByte (byte, str, index ; n)
- {
- n = (byte >> 4) & 15;
- str[index++] = (n <= 9 ? '0' : 'A' - 10) + n;
- n = byte & 15;
- str[index] = (n <= 9 ? '0' : 'A' - 10) + n;
- return str;
- }
-
-
- ProcessFile ( ; c, i, line, offset)
- {
- line = offset = "000000: ";
- i = 0;
-
- while ((c = getc(stdin)) != -1) {
- line += HexByte(c, " ??", 1);
- ++i;
- if ((i & 15) == 0) {
- print(line, "\n");
- line = HexByte(i >> 16,
- HexByte(i >> 8,
- HexByte(i, offset, 4),
- 2),
- 0);
- }
- }
- if (sizeof(line) != 0)
- print(line, "\n");
- print("<END>\n");
- }
-